<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="lib/js/vue.js" type="text/javascript" charset="utf-8"></script>
    <script src="lib/js/vue-router.js" type="text/javascript"></script>

</head>
<body>
<div id="app">
    <router-link to="/login?id=5">登录</router-link>
    <router-link to="/res">注册</router-link>


    <router-view></router-view>

</div>
<script>

    var login = {
        template:'<h1>登录----{{ $route.query.id }}</h1>',
        created() {
            console.log(this.$route)
        }
    }

    var res = {
        template:'<h1>注册组件</h1>'
    }

    var router = new VueRouter({
        routes:[
            {path:'/',redirect:'/login'},
            {path:'/login',component:login},
            {path:'/res',component:res}
        ]
    })
    // 创建一个vue实例
    new Vue({
        el:'#app',
        data:{
            msg:'信息'
        },
        methods:{

        },
        router : router
    })
</script>
</body>
</html>
